﻿@using System.Web.UI.WebControls
@{
    ViewBag.Title = "GetAccessToken";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<input id="CorpId" placeholder="CorpId" />
<input id="CorpSecret" placeholder="CorpSecret" />
<div style="height: 20px;width: 100%;margin-top: 10px;margin-left: 5px;">返回结果：</div>
@Html.TextArea("AccessToken", new { @style = "width: 100%;height: 200px;margin-top: 10px;", @readonly = true })
<input type="button" onclick="submit()" value="提交" />

<script type="text/javascript">
    function submit() {
        var corpId = $("#CorpId").val();
        var corpSecret = $("#CorpSecret").val();
        if ($.isEmptyObject(corpId)) {
            alert("CorpId不能为空!");
            return false;
        }

        if ($.isEmptyObject(corpSecret)) {
            alert("CorpSecret不能为空!");
            return false;
        }
        $.ajax({
            url: "/QyWeiXin/GetAccessToken",
            type: "POST",
            data: {
                "corpId": corpId, "corpSecret": corpSecret
            },
            success: function (res) {
                $("#AccessToken").val(res);
            }
        });
    }
</script>